package calorie.com.calorie.contact;

import android.content.Context;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;

import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.request.HashChargeRequest;
import calorie.com.calorie.response.TransferAccountResponce;
import retrofit2.Call;
import retrofit2.Response;


public class HashChargeContact {
    public static class HashChargePresent extends BasePresent<IHashChargeView> {
        public void hashCharge(Context context,String hashCode,String type){
            ApiService service= ServiceGenerator.createService(ApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            HashChargeRequest request=new HashChargeRequest(userId,hashCode,type);
            service.hashCharge(request).enqueue(new NetCallBack<TransferAccountResponce>() {
                @Override
                public void onSuccess(Call<TransferAccountResponce> call, Response<TransferAccountResponce> response) {
                    if (getView()!=null){
                        getView().getHashChargeData(response);
                    }
                }

                @Override
                public void onFailed() {
                   // ToastUtils.showLongToast(context,"网络请求异常");
                }
            });

        }
    }
    public interface IHashChargeView extends IBaseView {
        void getHashChargeData(Response<TransferAccountResponce> response);
    }
}
